package com.ruoyi.security.controller;

import java.util.List;
import java.io.IOException;
import javax.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import com.ruoyi.common.log.annotation.Log;
import com.ruoyi.common.log.enums.BusinessType;
import com.ruoyi.common.security.annotation.PreAuthorize;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import com.ruoyi.security.domain.AfFirHydrant;
import com.ruoyi.security.service.IAfFirHydrantService;
import com.ruoyi.common.core.web.controller.BaseController;
import com.ruoyi.common.core.web.domain.AjaxResult;
import com.ruoyi.common.core.utils.poi.ExcelUtil;
import com.ruoyi.common.core.web.page.TableDataInfo;

/**
 * 消防栓台账Controller
 *
 * @author cjie
 * @date 2022-01-22
 */
@Api(tags = " 消防栓台账")
@RestController
@RequestMapping("/afFirHydrant")
public class AfFirHydrantController extends BaseController {
    @Autowired
    private IAfFirHydrantService afFirHydrantService;

    /**
     * 查询消防栓台账列表
     */
    @ApiOperation(value="查询消防栓台账列表", notes="查询消防栓台账列表")
    @PreAuthorize(hasPermi = "security:afFirHydrant:list")
    @GetMapping("/list")
    public TableDataInfo list(AfFirHydrant afFirHydrant) {
        startPage();
        List<AfFirHydrant> list = afFirHydrantService.selectAfFirHydrantList(afFirHydrant);
        return getDataTable(list);
    }

    /**
     * 导出消防栓台账列表
     */
    @ApiOperation(value="导出消防栓台账列表", notes="导出消防栓台账列表")
    @PreAuthorize(hasPermi = "security:afFirHydrant:export")
    @Log(title = "消防栓台账", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, AfFirHydrant afFirHydrant) throws IOException {
        List<AfFirHydrant> list = afFirHydrantService.selectAfFirHydrantList(afFirHydrant);
        ExcelUtil<AfFirHydrant> util = new ExcelUtil<AfFirHydrant>(AfFirHydrant.class);
        util.exportExcel(response, list, "消防栓台账数据");
    }
    /**
     * 获取消防栓台账详细信息
     */
    @ApiOperation(value="获取消防栓台账详细信息", notes="获取消防栓台账详细信息")
    @PreAuthorize(hasPermi = "security:afFirHydrant:query")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") String id) {
        return AjaxResult.success(afFirHydrantService.selectAfFirHydrantById(id));
    }

    /**
     * 新增消防栓台账
     */
    @ApiOperation(value="新增消防栓台账", notes="新增消防栓台账")
    @PreAuthorize(hasPermi = "security:afFirHydrant:add")
    @Log(title = "消防栓台账", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody AfFirHydrant afFirHydrant) {
        return toAjax(afFirHydrantService.insertAfFirHydrant(afFirHydrant));
    }

    /**
     * 修改消防栓台账
     */
    @ApiOperation(value="修改消防栓台账", notes="修改消防栓台账")
    @PreAuthorize(hasPermi = "security:afFirHydrant:edit")
    @Log(title = "消防栓台账", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody AfFirHydrant afFirHydrant) {
        return toAjax(afFirHydrantService.updateAfFirHydrant(afFirHydrant));
    }

    /**
     * 删除消防栓台账
     */
    @ApiOperation(value="删除消防栓台账", notes="删除消防栓台账")
    @ApiImplicitParam(name = "ids", value = "消防栓台账ID数组", required = true,paramType = "path", allowMultiple=true, dataType = "String")
    @PreAuthorize(hasPermi = "security:afFirHydrant:remove")
    @Log(title = "消防栓台账", businessType = BusinessType.DELETE)
    @DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable String[] ids) {
        return toAjax(afFirHydrantService.deleteAfFirHydrantByIds(ids));
    }
}
